#ifndef DEFINES_H
#define DEFINES_H

//#define EIGEN_NO_DEBUG
#define EIGEN_DONT_PARALLELIZE
#include <Eigen/Dense>
#include <iostream>
#include <vector>
#include <list>
#include <string>
#include <cmath>

//#define Fitness_By_Accuracy

//#define logsig(x) 1.0/(1.0+(-(x)).array.exp())

const int RawDim=52;
const int InputCount=4;
typedef Eigen::Vector<double,RawDim> RawData;

typedef Eigen::Vector<double,InputCount+1> Input;// single statue

const int HiddenCount=24;
typedef Eigen::Matrix<double,HiddenCount,InputCount+1> In2Hid;//U
typedef Eigen::Vector<double,HiddenCount+1> HiddenLayer;
typedef Eigen::Matrix<double,HiddenCount,HiddenCount> Hid2Hid;//W

const int OutputCount=2;
typedef Eigen::Vector<double,OutputCount> OutLayer;
typedef Eigen::Matrix<double,2,HiddenCount+1> Hid2Out;//V

const int SampleLength=48;
typedef std::pair<const Input*,bool> Sample;

const OutLayer normalOut={0.8,0.2},abnormalOut={0.2,0.8};

const double LearningRate=0.01;

//typedef std::vector<Sample> Batch;
const int SuggestedBatchSize=50;
const int DataSetSize=2000;
const double normalRatio=0.3;


const int populationSize=50;
//种群规模
const double crossoverProb=0.8;
//交叉概率
#define CROSSOVER_BY_DISCRETE_SWAP

const double mutateProb=0.05;
//变异概率
const int maxGeneration=20-1;
//最大允许代数
const int maxFailTimes=50;
//连续50代没有更优的个体产生，则结束

const double iniWeightScale=0.9;
//权值初始化范围-0.5~0.5

double randDouble();

void writeMatrixAsMatlab(const Eigen::MatrixXd,std::fstream&);

const RawData RawDim_Mean=
{0.255445187,3663.258442,4509.021855,9.394672222,26.90497951,42.37553075,2724.016801,74.83207361,120.4014003,0.34397998,79.72944826,49.96965546,2652.243413,25.11228328,49.94973423,3121.600263,22.89507148,65.99116582,245.7803008,341.0187257,94.42974529,77.13254162,32.03951627,8.862998333,26.79910218,6.865766756,18.64901865,1.625957666,32.7324631,13.78168056,24.59984335,1.246595047,18.38436319,2.218931141,4.773760188,2.264731915,0.017822685,0.834336979,0.0971788,53.70220089,43.83441617,64.42603056,54.76671567,29.05446208,64.00989077,22.25522226,39.22504439,38.01071582,46.41767371,49.09230587,42.26514623,21.07361453,};

const Eigen::Matrix<double,InputCount,RawDim> PCA_TransMat=
        Eigen::Matrix<double,InputCount,RawDim>({
{-0.000446847313353850,-0.000477344161873394,-0.182208877766480,0.00141367637541828,-1.93304913085101e-05,0.000643546115805763,0.511943612356628,-0.00356715080515202,3.61604721418966e-05,-0.000224487684757297,-0.0111214983630109,-0.000370959880910764,0.514688174470404,-0.00105689232858533,-0.00110403699330127,0.523897352210988,-0.00131820225221261,0.00417388467721404,0.380988117352271,-0.00340500788550643,-5.92647056459648e-05,-0.00514683038725108,-0.00486235289668945,-0.000854003801526567,0.0112140834822135,-0.000424393988175372,-0.00303799776190353,-0.000133651027493155,-0.00715416613757608,-0.00112201160934401,0.0169134871893477,-0.000366227705392107,-0.00475148786244981,-0.000268037493739118,-0.00217167842332934,-0.00110142601089336,-6.13262206039004e-07,-1.93394456453156e-05,2.36054317934181e-06,0.000122544416848396,-0.000382503553029416,0.0323305402235399,0.0110798656600719,0.0580723866159693,0.0534566826366701,0.0118019418343107,-0.0676816198883047,-0.00109121041263644,-0.00255493590867789,0.0347976753491329,0.0330832353633107,0.0709378147397387},
{-0.000279940883734820,0.222331970447687,0.917256679073809,0.00129943469791161,-3.64954576104401e-05,0.00107442239679491,0.163420696854644,0.000826556432003837,-7.27937595212066e-05,0.000147032388357155,-0.00268822330774059,-0.00122510139125894,0.185674176828137,-0.00226561488714781,-0.000639498776711063,0.0681377256981773,-0.000562246274447825,-0.00312978076529984,-0.0989124138786643,0.0752220000374526,-0.00291703878348379,0.00141887859014756,0.00942054519425951,-0.000982885076276059,-0.000501774583248420,-0.000432170613350571,-0.00682731747256241,-0.000382231941126200,0.0146561217441130,-0.00128108777261250,-0.00180007236971908,-0.000755774597057530,-0.00975472141862202,-0.000492919291607060,-0.000496637423754904,-0.000108748127463852,-1.67524687085495e-05,-0.000630651857598367,-4.32235216430550e-05,-0.00209263963995053,0.00246222046197252,0.0183177844355677,0.0489358825583495,-0.0955044431603360,0.00956612115341701,-0.0243651836126360,0.00240167655444700,-0.00360658416678579,-0.00147989975902829,-0.102446095493908,-0.0659392927380795,0.00630882904140382},
{0.000285449680650062,0.505011861195093,0.00592512375111554,0.00216047788278473,-0.000102690805921735,0.00236253653345075,-0.145169849669834,-0.0114640694010282,-1.38383705352340e-05,-0.000248943242309127,0.00203209887636980,-0.00118903812727864,-0.116329942364004,-0.000895435842947985,-0.000526091009766012,-0.285991056298103,0.000619280960485863,0.0328804825088575,0.756544885422526,0.113778234119348,-0.00599866943894168,0.00322786072422603,0.0195285211740433,-0.000415627647960812,-0.0145157575485068,-0.000644792275629821,-0.00666153380410081,0.00113863410777508,0.0296900493728698,0.000126282333373724,-0.0238019842581505,-0.000655571677170687,-0.00823575970659548,0.00168538186544663,0.000833454804251734,0.000615157588368005,-2.09338224999112e-05,-0.000944000251833009,-2.33357624176554e-05,-0.00286253747429207,0.00290967424795155,0.0242895289223413,0.0617016269960987,-0.103050690659691,0.0125642885726686,-0.0513035430789335,-0.0457120306074779,-0.00350136164167713,-0.00121737794926329,0.0891548034692131,-0.109148990928173,0.000355347218002273},
{-0.000309983154670942,0.823808476732635,-0.283925075661978,3.47420156962819e-05,-4.43201281106198e-05,0.000127384354173032,0.0656256540733498,0.00302903660771491,0.000169031330375180,0.000232221331377470,0.000383771196345653,0.000269931874164202,0.0568493881059936,-0.000185357140102325,0.000188059011364717,0.118889158857551,-0.000361157525575322,-0.0184921067605595,-0.453774712215483,-0.0318829976952656,-0.000522474892893236,0.000506598753701616,-0.00567789541800694,-0.000260807334999020,0.00482211798126084,7.90338683949052e-05,0.00225001725635027,-0.000760634979329248,-0.00889727046656711,-0.000609472785711630,0.00747582648069852,-0.000125125006333475,0.00315430113993941,-0.00102150845395448,-1.89690691483698e-05,-0.000183778826481921,-2.70225946612323e-07,0.000391545784154602,-8.52821167343787e-06,0.00211250693885275,-0.00247379446739222,0.00131403090425537,-0.0175429174134768,0.00419952686638140,0.000425235259314115,0.0127915402266322,0.0318256280798348,0.000795150167597817,0.000435148245023284,-0.0930279845282200,0.0373535599172042,0.000351938171769414},
});

#endif // DEFINES_H
